home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / network / nsclilib / ni_defin.h < prev    next >
Text File  |  1996-07-05  |  16KB  |  374 lines

  1. /*
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE
  5. *               National Center for Biotechnology Information
  6. *
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and
  10. *  thus cannot be copyrighted.  This software/database is freely available
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government have not placed any restriction on its use or reproduction.
  13. *
  14. *  Although all reasonable efforts have been taken to ensure the accuracy
  15. *  and reliability of the software and data, the NLM and the U.S.
  16. *  Government do not and cannot warrant the performance or results that
  17. *  may be obtained by using this software or data. The NLM and the U.S.
  18. *  Government disclaim all warranties, express or implied, including
  19. *  warranties of performance, merchantability or fitness for any particular
  20. *  purpose.
  21. *
  22. *  Please cite the author in any work or product based on this material.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:    ni_defin.h
  27. *
  28. * Author:       Beatty, Gish
  29. *
  30. * Version Creation Date:        1/1/92
  31. *
  32. * $Revision: 4.0 $
  33. *
  34. * File Description:
  35. *
  36. *
  37. * Modifications:
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. * 5/12/92  Epstein     Converted tabs to spaces
  42. * 5/06/92  Epstein     Added conditionally-compiled option for use with the
  43. *                      "purify" tool
  44. * 01-21-94 Schuler     Added NETP_INET_MACTCP symbol
  45. *
  46. * ==========================================================================
  47. *
  48. *
  49. * RCS Modification History:
  50. * $Log: ni_defin.h,v $
  51.  * Revision 4.0  1995/07/26  13:56:32  ostell
  52.  * force revision to 4.0
  53.  *
  54.  * Revision 1.24  1995/05/17  17:51:56  epstein
  55.  * add RCS log revision history
  56.  *
  57. */
  58.  
  59. #ifndef _NI_DEFIN_
  60. #define _NI_DEFIN_
  61.  
  62. #define STDIN           0
  63. #define STDOUT          1
  64. #define STDERR          STDOUT + 1
  65.  
  66. /* if the "purify" tool is in use, it will seize the file descriptor which    */
  67. /* we had wanted; this is O.K., but the difference must be taken into account */
  68. /* here                                                                       */
  69. #ifndef _PURIFY
  70. #define STDPIPE         STDERR + 1
  71. #else
  72. #define STDPIPE         STDERR + 2
  73. #endif
  74.  
  75. #define NI_Handle       MHandle                 /* for API use */
  76. #define NI_HandPtr      MHandPtr                /* for API use */
  77. #define NI_Request      Request                 /* for API use */
  78. #define NI_ReqPtr       ReqPtr                  /* for API use */
  79.  
  80. #define ERRTEXT_BUFSIZ  512                     /* size of supplied error text buffer */
  81. #define HOSTNAME_SIZ    64
  82. #define INETADDR_SIZ    16                      /* of the form 255.255.255.255 */
  83. #define SVC_HOST_SIZ    64                      /* size of addr or name of host */
  84. #define SVC_NAME_SIZ    64                      /* size of name of service */
  85. #define RES_NAME_SIZ    64                      /* size of name of resource */
  86. #define RESTYP_NAME_SIZ 64                      /* size of type of resource */
  87. #define USERNAME_SIZ    64                      /* kerberos principle */
  88. #define GROUPNAME_SIZ   64                      /* kerberos instance */
  89. #define DOMAINNAME_SIZ  64                      /* kerberos realm */
  90. #define PASSWORD_SIZ    32                      /* must be encrypted */
  91.  
  92. #define MATCHES_ANY_TYPE  "*"                   /* string which matches any resource type */
  93.  
  94. #define NI_LAST_RESERVED_PORT   1024            /* ports above this MAY be legal */
  95.  
  96. #define NI_DEFAULT_TIMEOUT      60
  97. #define NI_SELECT_TIMEOUT       60
  98. #define NI_READ_TIMEOUT         NI_DEFAULT_TIMEOUT
  99. #define NI_WRITE_TIMEOUT        NI_DEFAULT_TIMEOUT
  100.  
  101. #define PIPE_TOKEN      "\003"
  102. #define PIPE_MSG_FMT    "%d\003%s\003"
  103.  
  104. #define READ_AIP                raip
  105. #define WRITE_AIP               waip
  106.  
  107. #define NI_DEFAULT_DOMAIN       "ncbi.nlm.nih.gov"      /* default domain */
  108. #define NI_DEFAULT_HOST         "dispatcher"            /* default host for dispatcher */
  109. #define NI_DEFAULT_SERVICE      "disp_port"             /* default name of service (port) */
  110. #define NI_DFLT_SVC_PORT        5557                    /* default port for service */
  111.  
  112. #define NI_CLIENT_PORT_LO_NAME  "ncbi_begin"            /* beginning of client port range */
  113. #define NI_DFLT_CLILO_PORT      5601                    /* default beginning of client port range */
  114. #define NI_CLIENT_PORT_HI_NAME  "ncbi_end"              /* end of client port range */
  115. #define NI_DFLT_CLIHI_PORT      32767                   /* default end of client port range */
  116.  
  117.  
  118. /* instrumentation is enabled by default */
  119. #ifdef NI_NOSOCK_LOGGING
  120. #define LOG_SOCKET(x,y)
  121. #else
  122. #define LOG_SOCKET(x,y) NI_LogSocket(x,y,__FILE__,__LINE__)
  123. #endif /* NI_NOSOCK_LOGGING */
  124.  
  125.  
  126. #ifdef NETP_INET_WSOCK
  127. /* ** the following was extracted from <winsock.h> ** */
  128. /*
  129.  * Windows Sockets errors redefined as regular Berkeley error constants.
  130.  * These are commented out in Windows NT to avoid conflicts with errno.h.
  131.  * Use the WSA constants instead.
  132.  */
  133. #define EWOULDBLOCK             WSAEWOULDBLOCK
  134. #define EINPROGRESS             WSAEINPROGRESS
  135. #define EALREADY                WSAEALREADY
  136. #define ENOTSOCK                WSAENOTSOCK
  137. #define EDESTADDRREQ            WSAEDESTADDRREQ
  138. #define EMSGSIZE                WSAEMSGSIZE
  139. #define EPROTOTYPE              WSAEPROTOTYPE
  140. #define ENOPROTOOPT             WSAENOPROTOOPT
  141. #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
  142. #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
  143. #define EOPNOTSUPP              WSAEOPNOTSUPP
  144. #define EPFNOSUPPORT            WSAEPFNOSUPPORT
  145. #define EAFNOSUPPORT            WSAEAFNOSUPPORT
  146. #define EADDRINUSE              WSAEADDRINUSE
  147. #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
  148. #define ENETDOWN                WSAENETDOWN
  149. #define ENETUNREACH             WSAENETUNREACH
  150. #define ENETRESET               WSAENETRESET
  151. #define ECONNABORTED            WSAECONNABORTED
  152. #define ECONNRESET              WSAECONNRESET
  153. #define ENOBUFS                 WSAENOBUFS
  154. #define EISCONN                 WSAEISCONN
  155. #define ENOTCONN                WSAENOTCONN
  156. #define ESHUTDOWN               WSAESHUTDOWN
  157. #define ETOOMANYREFS            WSAETOOMANYREFS
  158. #define ETIMEDOUT               WSAETIMEDOUT
  159. #define ECONNREFUSED            WSAECONNREFUSED
  160. #define ELOOP                   WSAELOOP
  161. //#define ENAMETOOLONG            WSAENAMETOOLONG
  162. #define EHOSTDOWN               WSAEHOSTDOWN
  163. #define EHOSTUNREACH            WSAEHOSTUNREACH
  164. //#define ENOTEMPTY               WSAENOTEMPTY
  165. #define EPROCLIM                WSAEPROCLIM
  166. #define EUSERS                  WSAEUSERS
  167. #define EDQUOT                  WSAEDQUOT
  168. #define ESTALE                  WSAESTALE
  169. #define EREMOTE                 WSAEREMOTE
  170. #endif  /* NETP_INET_WSOCK */
  171.  
  172.  
  173. /* MACROS */
  174.  
  175. /* BLOCKSIG, UNBLOCKSIG, and BZERO are for dispatcher and ncbid only */
  176. #if defined(OS_UNIX_SYSV) && !defined(PROC_MIPS)
  177. /* for System V we cheat and use the caller's "mask" variable to store     */
  178. /* the signal; note that these macros won't work if dealing with more than */
  179. /* one signal                                                              */
  180. #define NI_BLOCKSIG(_sig, _mask)                { _mask = _sig; sighold(_sig); }
  181. #define NI_UNBLOCKSIG(_sig)                     sigrelse(_sig)
  182. #define NI_BZERO(buf, bufsize)                  Nlm_MemFill(buf, 0, bufsize)
  183. #else
  184. #define NI_BLOCKSIG(_sig, _mask)                _mask = sigblock(sigmask(_sig))
  185. #define NI_UNBLOCKSIG(_mask)                    sigsetmask(_mask)
  186. #define NI_BZERO(buf, bufsize)                  bzero(buf, bufsize)
  187. #endif
  188.  
  189.  
  190. #ifdef NETP_INET_NEWT
  191. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  192. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  193. #define NI_CLOSESOCKET(sok)                     close_socket(sok)
  194. #define NI_select(s, r, w, x, t)                NI_poll_select(s, r, w, x, t)
  195. #define NI_SETBLOCKING(fd)                      ioctl(fd, FIONBIO, "1")
  196. #define NI_SETNONBLOCKING(fd)                   ioctl(fd, FIONBIO, "0")
  197. #endif /* NETP_INET_NEWT */
  198.  
  199. #ifdef NETP_INET_PCNFS
  200. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  201. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  202. #define NI_CLOSESOCKET(sok)                     close(sok)
  203. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  204. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  205. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  206. #define NI_BLOCK_WITH_FUNCTION
  207. #endif /* NETP_INET_PCNFS */
  208.  
  209. /* Windows Sockets */
  210. #ifdef NETP_INET_WSOCK
  211. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  212. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  213. #define NI_CLOSESOCKET(sok)                     closesocket(sok)
  214. #define NI_select(s, r, w, x, t)                NI_poll_select(s, r, w, x, t)
  215. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  216. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  217. #define errno                                   WSAGetLastError()
  218. #define _INVALID_SOCKET_DEFINED_
  219. #define NI_BLOCK_WITH_FUNCTION
  220. #define SOCK_INDEX_ERRNO                        ((errno <= WSABASEERR || errno >= sys_nerr + WSABASEERR) ? 0 : (errno - WSABASEERR))
  221. #endif /* NETP_INET_WINSOCK */
  222.  
  223. /* TGV's Multinet TCP/IP suite for OpenVMS */
  224. #ifdef NETP_INET_TGV
  225. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  226. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  227. #define NI_CLOSESOCKET(sok)                     socket_close(sok)
  228. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  229. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  230. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  231. #define NI_BLOCK_WITH_FUNCTION
  232. #define SOCK_ERRNO                              socket_errno
  233. #endif
  234.  
  235. /* Wollongong TCP/IP suite for OpenVMS */
  236. #ifdef NETP_INET_TWG
  237. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  238. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  239. #define NI_CLOSESOCKET(sok)                     netclose(sok)
  240. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  241. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  242. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  243. #define NI_BLOCK_WITH_FUNCTION
  244. /* from UCX */
  245. #define FD_SETSIZE                              32
  246. #define fd_set                                  int
  247. #define FD_SET(n, p)                            *(p) |= 1 << (n);
  248. #define FD_CLR(n,p)                             *(p) &= ~(1 << (n));
  249. #define FD_ISSET(n,p)                           ((*p) & (1 << (n)))
  250. #define FD_ZERO(p)                              *(p) = 0;
  251. #endif
  252.  
  253. /* Wollongong PathWay API 1.0 suite for OpenVMS */
  254. #ifdef NETP_INET_WPW
  255. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  256. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  257. #define NI_CLOSESOCKET(sok)                     netclose(sok)
  258. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  259. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  260. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  261. #define NI_BLOCK_WITH_FUNCTION
  262. #endif
  263.  
  264. /* DEC TCP/IP for OpenVMS (UCX) */
  265. #ifdef NETP_INET_UCX
  266. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  267. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  268. #define NI_CLOSESOCKET(sok)                     close(sok)
  269. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  270. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  271. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  272. #define NI_BLOCK_WITH_FUNCTION
  273. #define FD_SETSIZE                              32
  274. #define fd_set                                  int
  275. #define FD_SET(n, p)                            *(p) |= 1 << (n);
  276. #define FD_CLR(n,p)                             *(p) &= ~(1 << (n));
  277. #define FD_ISSET(n,p)                           ((*p) & (1 << (n)))
  278. #define FD_ZERO(p)                              *(p) = 0;
  279. #endif
  280.  
  281.  
  282. /* Macintosh */
  283. #if defined(OS_MAC) && !defined(NETP_defined)
  284. #define NETP_INET_MACTCP
  285. #endif
  286.  
  287. #ifdef NETP_INET_MACTCP
  288. #define NI_READSOCKET(rsok, rbuf, rlen)         read(rsok, rbuf, rlen)
  289. #define NI_WRITESOCKET(wsok, wbuf, wlen)        write(wsok, wbuf, wlen)
  290. #define NI_CLOSESOCKET(sok)                     close(sok)
  291. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  292. #define NI_SETBLOCKING(fd)      fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY)       /* set blocking */
  293. #define NI_SETNONBLOCKING(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY)        /* set nonblocking */
  294.  
  295. /* The errno_long mechanism is used for interoperability between the           */
  296. /* network services library and the NCSA socket library, which need not have   */
  297. /* been compiled with the same integer size (2 byte vs. 4 byte)                */
  298. #define SOCK_ERRNO errno_long
  299. #endif /* NETP_INET_MACTCP */
  300.  
  301.  
  302. #ifndef NI_READSOCKET /* for now, fall back on UNIX as default */
  303. #define NI_READSOCKET(rsok, rbuf, rlen)         read(rsok, rbuf, rlen)
  304. #define NI_WRITESOCKET(wsok, wbuf, wlen)        write(wsok, wbuf, wlen)
  305. #define NI_CLOSESOCKET(sok)                     close(sok)
  306. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  307.  
  308. #ifdef OS_UNIX_BSD
  309. #define NI_SETBLOCKING(fd)      fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~FNDELAY)       /* set blocking */
  310. #define NI_SETNONBLOCKING(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FNDELAY)        /* set nonblocking */
  311. #else
  312. #define NI_SETBLOCKING(fd)      fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY)       /* set blocking */
  313. #define NI_SETNONBLOCKING(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY)        /* set nonblocking */
  314. #endif /* OS_UNIX_BSD */
  315.  
  316. #endif /* NI_READSOCKET */
  317.  
  318. /* MSDOS  */
  319.  
  320. #ifdef COMP_MSC
  321. #ifndef NETP_INET_MACTCP
  322. #ifdef FD_SETSIZE
  323. #undef FD_SETSIZE
  324. #endif
  325. #define FD_SETSIZE      32
  326. #include <io.h>
  327.  
  328. #ifndef NETP_INET_NEWT
  329. #ifndef NETP_INET_PCNFS
  330. #ifndef NETP_INET_WSOCK
  331. /* copied from Sun version of this file 6-11-91 and modified */
  332. #define NFDBITS         32
  333. #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  334. #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  335. #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  336. #define FD_ZERO(p)      MemFill((char *)(p), '\0', sizeof(*(p)))
  337. #endif
  338. #endif
  339. #endif
  340.  
  341. #endif  /* NETP_INET_MACTCP */
  342. #endif  /* COMP_MSC */
  343.  
  344. #ifndef SOCK_ERRNO
  345. #define SOCK_ERRNO errno
  346. #endif /* SOCK_ERRNO */
  347.  
  348. #ifndef SOCK_INDEX_ERRNO
  349. #define SOCK_INDEX_ERRNO SOCK_ERRNO
  350. #endif /* SOCK_INDEX_ERRNO */
  351.  
  352. #ifndef _INVALID_SOCKET_DEFINED_
  353. #define INVALID_SOCKET -1
  354. #endif /* INVALID_SOCKET */
  355.  
  356. #ifdef NETP_SOCKS
  357. #define NI_ACCEPT(sok,addr,addrlen)         Raccept(sok,addr,addrlen)
  358. #define NI_BIND(sok,name,namelen,bindaddr)  Rbind(sok,name,namelen,bindaddr)
  359. #define NI_CONNECT(sok,name,namelen)        Rconnect(sok,name,namelen)
  360. #define NI_GETSOCKNAME(sok,name,namelen)    Rgetsockname(sok,name,namelen)
  361. #define NI_LISTEN(sok,backlog)              Rlisten(sok,backlog)
  362. #else
  363. #define NI_ACCEPT(sok,addr,addrlen)         accept(sok,addr,addrlen)
  364. #define NI_BIND(sok,name,namelen,bindaddr)  bind(sok,name,namelen)
  365. #define NI_CONNECT(sok,name,namelen)        connect(sok,name,namelen)
  366. #define NI_GETSOCKNAME(sok,name,namelen)    getsockname(sok,name,namelen)
  367. #define NI_LISTEN(sok,backlog)              listen(sok,backlog)
  368. #endif
  369.  
  370.  
  371. #endif  /* _NI_DEFIN_ */
  372.  
  373.  
  374.